package com.zenika.zenbinding.client.handler;

import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;
import com.zenika.zenbinding.client.model.ValueModel;

public class LabelHandler extends ValueBindingHandler {

	private Label label;
	private ValueModel model;

	public LabelHandler(Label label, ValueModel model) {
		super();
		this.label = label;
		this.model = model;
		this.model.setHandler(this);
		this.bind();
	}

	private void bind() {
		this.label.setText(this.model.getValue());
	}

	public void setRegularStyle() {
		this.label.setStyleName("gwt-Label");
	}

	public void setErrorStyle() {
		this.label.setStyleName("error-Label");
	}

	public Widget getWidget() {
		return this.label;
	}

	public Object getValue() {
		return this.label.getText();
	}

}
